package controller.hansot;

import java.sql.SQLException;
import java.util.ArrayList;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import hansot.model.dao.HansotDAO;
import hansot.to.MenuTO;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import service.hansot.CustomerService;

@Controller
public class TilesController {
	private CustomerService service;

	public TilesController(CustomerService service) {
		this.service = service;
	}

	@RequestMapping("/mainPage.do")
	public ModelAndView mainPage(HttpServletRequest request,
			HttpServletResponse response) {
		ModelAndView mv = new ModelAndView();
		try {
			HttpSession session = request.getSession();
			ArrayList<MenuTO> list = service.gradeSearch();
			session.setAttribute("list", list);
			mv.setViewName("메인/main");
		} catch (SQLException e) {
			mv = new ModelAndView("/error", "error_message",
					"메인페이지 오류발생 : " + e.getMessage());
		}
		return mv;// tile 설정 - definition name 속성의 값을 viewName으로 return.
	}

	@RequestMapping("/registerForm.do")
	public String registerForm() {
		return "가입폼/join_form";
	}

	@RequestMapping("/memberUpdate.do")
	public String memberUpdateForm(){
		return "수정폼/register_update_form";
	}
	
	@RequestMapping("/registerMember.do")
	public ModelAndView registerMember(HansotDAO mdto) {
		System.out.println("회원 등록 처리 - 데이터 : " + mdto);
		return new ModelAndView("등록성공/register_success", "mdto", mdto);
	}
	
	@RequestMapping("/login_member.do")
	public String loginMember(){
		return "로그인/login_member";
	}
/*
	@RequestMapping("/myjsp.do")
	public ModelAndView myjsp() {
		return new ModelAndView("myjsp");
	}

	@RequestMapping("/yourjsp.do")
	public String yourjsp() {
		return null;
	}
	*/
	
	// 건드리기 시작한 부분 left.jsp
		@RequestMapping("/subMenu1.do")
		public String subMenu1(){
			return "subMenu1";
		}
		
	
		
		
		//건드린 부분 마지막
	
}
